Method and apparatus for a phototransistor pulse width converter

ABSTRACT

A system for measuring output voltage from a photodetector. The system includes a photodetector that generates a photodetector output signal, a ramp generator that generates a ramp signal and a comparator that outputs a signal level based on which of the two signals is larger. The voltage level of the output of the phototransistor determines how long it will take for the ramp voltage to catch up and cross over the phototransistor voltage. The crossover time determines the width of an output signal and is directly proportional to the voltage level. A microcontroller can then determine the pulse width by multiple samplings and therefore determine photodetector voltage

BACKGROUND

[0001] 1. Field

[0002] This disclosure relates to circuits for converting a varyingvoltage level to a varying width pulse, more particularly to a circuitmaking that conversion such that the varying width pulse can be sampled.

[0003] 2. Background

[0004] Optical couplers typically include an emitter and detector pair.The detector detects emission or lack of emission from the emitter. Theemitter is typically a source of light, such as a Light-Emitting Diode(LED) and the detector may be a phototransistor. The voltage leveloutput by the phototransistor is directly related to the amount of lightdetected from the emitter.

[0005] A common application of these pairs is in user pointing devices,such as a computer mouse. These devices may use the pairs in quadraturephase decoding. Quadrature phase decoding may be used to detect movementof an object. In a typical configuration, a decoder wheel is used, insetsuch that there are slots around the wheel. A phototransistor with twooutputs A and B is positioned such that the A and B photosensors arealigned with the slots and offset so that their quadrature outputs are90 degrees out of phase. As the decoder wheels spin, they determine theoutputs for A and B as either one (1) or zero (0). This results in the Aand B outputs, typically sine waves, being ninety degrees out of phasewith each other. The two digital outputs then create four possibleoutputs, hence the name quadrature.

[0006] Alternatively, photosensors can be used to detect movement ofother objects between the photosensor and the emitter. In some examplesthe emitters are light emitting diodes (LEDs). The LEDs are left in theON state and interruption of the light emitted and the detectorindicates movement of an object in between the two, whether that objectis a decoder wheel shutter or some other type of object.

[0007] Converting the output of a photodetector to a 1 or 0 isdifficult. Variations in output brightness of the LED, and photodetectorsensitivity, along with manufacturing variations, may make itimpractical to use a standard photodetector output value for thethreshold. There may need to be a different threshold value for eachphotodetector output. To lower manufacturing costs, it's desirable thatthere be some sort of automatic method to find the threshold values of awide range devices.

[0008] Another problem with any sensor with a binary output is theproblem of what happens to the output when the input is sitting at thethreshold value. The output could then be either a 1 or 0. Usually,system noise causes the input to vary slightly, which could cause theoutput to change, even though the wheel is not moving. The common way toprevent false movement is with some form of hysterisis. With hysterisis,there are two thresholds—a high threshold and a low one. With inputvoltage hysterisis, if the input is low, it has to cross the highthreshold before the output changes, and conversely, if the input ishigh, it has to cross the low threshold. The two threshold points arefar enough apart to prevent noise on the input from causing outputoscillations. Voltage hysterisis is commonly done with positive feedbackfrom the output back to the input, so the output value (state)determines the input voltage threshold.

[0009] If the computer mouse or object with the optical coupler has alimited power supply, such as a battery, leaving the LED ON indefinitelywill unnecessarily consume power. However, pulsing the LED between OFFand ON could lead to inaccurate data because input hysterisis will notwork unless the state information is saved away between pulses. Onesolution might be to have analog to digital converters on the inputs andconvert the analog voltage to a digital value, which can then be storedin the microcontroller. The problem with this approach is the added costof analog to digital converters on inputs. Some technique is needed thatwill allow the LED to be pulsed to save power yet provide accurate data.

BRIEF DESCRIPTION OF THE DRAWINGS

[0010] The invention may be best understood by reading the disclosurewith reference to the drawings, wherein:

[0011]FIG. 1 is a diagram of one embodiment of a circuit in accordancewith the invention.

[0012]FIG. 2 is an oscilloscope trace of an input signal and a referencevoltage, in accordance with the invention.

[0013]FIG. 3 is an oscilloscope trace of the input signals and an outputsignal for a comparator, in accordance with the invention.

[0014]FIG. 4 is an oscilloscope trace of alternative input signals andan output signal for a comparator, in accordance with the invention.

[0015]FIG. 5 is an oscilloscope trace of other alternative input signalsand an output signal for a comparator, in accordance with the invention.

DETAILED DESCRIPTION OF THE EMBODIMENTS

[0016]FIG. 1 shows a circuit diagram of one embodiment of a circuit inaccordance with the invention. The outputs of the photodetector LQ402are QXA and QXB, which will be used to determine the outputs XA and XBmentioned previously. A similar circuit to that in FIG. 1 will be usedto determine the outputs YA and YB, but only one example of the circuitis necessary to understand application of the invention.

[0017] The signals X_LED_ON_(—)0 on line 14 and XY_AB_ON_(—)0 on line 12are identical and output from a microcontroller. They provide power tothe LEDs, resulting in the pulsing of the LEDs to save power. As can beseen in the oscilloscope traces of FIG. 3, these signals have a 25% dutycycle. At this duty cycle, the LEDs use approximately 25% of the powerthey would if they were ON continuously. Also shown is the signalV_(ref), which can be seen as a ramp. In this discussion, the signalwill be referred to as a ramp signal or ramp voltage. The ramp voltagehas a low shown at 30 increasing to a high voltage level shown at 32.

[0018] Referring back to FIG. 1, it can be seen that a ramp generatorcircuit 18, enclosed by the dotted box, generates the Vref signal. Theoutput of the ramp generator, the ramp signal, and the output of thephotodetector LQ402 on line 16 are compared by the comparator U401. Asimilar comparison is made for QXB, the output of the XB photodetector.As discussed previously, in quadrature phase decoding operations, twophotodetectors A and B are used for each axis.

[0019] There are problems with determining the threshold level ofvarious photodetector outputs, as well as problems when the LEDs arepulsed. However, it is possible to convert the photodetector outputvoltage level into a digital pulse of varying width. The width of thepulse will be sampled and analyzed and deemed to be either a 1 or a 0,according to methods and processes outside the scope of this disclosure.

[0020] The crossover time is the amount of time it takes for the rampsignal V_(ref) to reach a voltage level substantially equal to theoutput of the photodetector, QXA 16. As can be seen by the oscilloscopetrace in FIG. 4, the amount of time between the two vertical lines isthe crossover time. At the point in time shown by the right mostvertical line, V_(ref) is substantially equal to QXA. Since thesesignals are both inputs to the comparator U401D, the output of thecomparator, XA, goes low at this point. The output XA is repeatedlysampled by the microcontroller, which then determines the width of thepulse, thereby, determining the voltage level.

[0021] The purpose of the resistors RP402D and RP402C is to providepositive feedback to prevent any oscillation when the voltage levelcrosses the ramp reference voltage. When the phototransistor (PTR) levelstarts out higher than the ramp voltage, which is typically the case,the output of the comparator is high. This pulls the output of the PTRlevel slightly higher, since the output is fed back through the resistorto the positive input. When the ramp voltage crosses the PTR level, theoutput of the comparator goes low and pulls the PTR voltage slightlylower. This increases the gaps between the PTR voltage and the rampvoltage, preventing oscillations across the crossover point.

[0022] In this example, the voltage for QXA is relatively high. It takesthe ramp signal 34 microseconds to reach a commensurate voltage level.In further analysis done after the sampling, the resulting pulse mayhave a width that corresponds to a 1 output for XA. The analysis of thesamples and the parameters for determining what width corresponds to a 1or a 0 is beyond the scope of this disclosure.

[0023] However, a contrasting example is shown in FIG. 5. In thisinstance, QXA is relatively low. The photodetector is not receiving asmuch light. It only takes the ramp signal 8 microseconds to reach thecommensurate voltage level as QXA. As an example, the small width of theresulting pulse may be determined to be a 0.

[0024] The shape of the ramp signal V_(ref) determines the behavior ofthe output signal XA. A more detailed discussion of the ramp generatorcircuit 18 of FIG. 1 can be had with reference to FIG. 2. A generalconsideration for the specifics of a ramp generator is that the minimumand maximum voltage for each photodetector can vary 50%, or more, fromthe worst-case device to the best-case device. The circuit mustaccommodate the full range of these situations for better manufacturingtolerance for the device.

[0025] Another consideration is that the output of the comparator XA hasto be sampled with sufficient resolution to allow for the determinationof a 1 or 0. The rise of the ramp cannot be too fast, preventingcollection of a sufficient number of samples. In one implementation ofthe invention, 8 sample points were determined to be sufficientresolution to perform the necessary analysis. However, in othercircuits, more or less multiple samples may be used. In some embodimentsthe microcontroller may sample the pulse, store the results and performthe analysis on the stored results.

[0026] In one example of a method for determining if the voltage outputis a 1 or a 0, a circuit or software is used to determine when the PTRvoltage has changed states. For example, the PTR may start in the darkregion. As the decoder wheel spins, the PTR is exposed to more and morelight. After it reaches maximum exposure, resulting in maximum voltage,the wheel will continue to spin and the PTR will receive less light,dropping the PTR voltage. Another hysterisis analysis, similar to thatperformed on the crossover voltage, may be performed to determine whenthe voltage is a 1 and when it was a 0.

[0027] Specific consideration for the voltage generated in FIG. 2includes selection of the values of the voltage divider and thecapacitor. The slope of the resistor capacitor combination (RC) shouldbe chosen so that the difference between the minimum and maximum voltageof an average device is about 8 samples of the microcontroller, asmentioned above. Additionally, if a voltage divider such as that formedby R403 22 and R404 24 is used, the selection of the values of theseresistors will determine the lowest voltage point of the ramp signal.

[0028] In one example, the voltage point was set low enough such thatthe crossing point for an average minimum and maximum voltage of aworst-case, small signal, device is on the second microcontrollersample, or greater. Similarly, the high voltage level was set so thecrossing point for an average minimum and maximum voltage of a bestcase, highest signal level, device is on the second to the last sample,or sooner. This resulted in optimal operation of the circuit shown inFIG. 1.

[0029] In the particular example of FIG. 2, a Schottky diode D1 26 isused to speed the discharge of the capacitor C404 20 between pulses. Thelowest voltage point will be determined by any residual charge on thecapacitor and the values set for the voltage divider, as mention above.Therefore, it is desirable to discharge the capacitor between pulses toallow for a stable low voltage level for the ramp signal. The capacitorC404 20 is one of the main determinants of the slope of the ramp signal.As the capacitor charges up from the pulsed XY_AB_ON_(—)0 signal, thesignal ramps up.

[0030] In this manner, a method and apparatus for determining thenecessary output signals used in quadrature detection is provided. TheLEDs providing light to the photodetectors can be pulsed with the stateinformation stored between samples, resulting in more accurate data.This allows quadrature detection devices, such as that used in userpointing devices, to save power.

[0031] Thus, although there has been described to this point aparticular embodiment for a method and apparatus for pulsing LEDs inoptical detection systems, it is not intended that such specificreferences be considered as limitations upon the scope of this inventionexcept in-so-far as set forth in the following claims.

What is claimed is:
 1. A system for measuring output from aphotodetector comprising: a) a photodetector operable to generate aphotodetector output signal; b) a ramp generator operable to generate aramp signal; and c) a comparator operable to compare the ramp signalwith the photodetector output signal and generate an output signalresulting in a pulse width of length proportional to the time it takesthe ramp signal to exceed the photodetector output signal.
 2. The systemof claim 1, wherein the system further comprises a microcontrolleroperable to repeatedly sample the photodetector output signal and storeresulting samples.
 3. The system of claim 1, wherein the ramp generatorfurther comprises a capacitor coupled to a pulsed input signal.
 4. Thesystem of claim 3, wherein the ramp generator further comprises aresistor divider and a diode coupled to the capacitor.
 5. A system forgenerating a ramp voltage signal comprising: a) a capacitor operable togenerate a ramp signal, wherein the ramp voltage signal has a lowvoltage level; and b) a voltage divider operable to set the low voltagelevel of the ramp voltage.
 6. The system of claim 5, wherein the rampsignal is used as an input to a comparator.
 7. The system of claim 6,wherein an output signal of the comparator is sampled.
 8. The system ofclaim 7, wherein hysterisis is used to prevent oscillations in thesample values.
 9. The system of claim 7, wherein the values of thecapacitor and the voltage divider are set such that multiple samples ofthe output of the comparator can be obtained during the period of timebetween the ramp voltage being substantially equal to the lowphotodetector voltage level and the ramp voltage being substantiallyequal to a high photodetector voltage level.
 10. A method of convertinga varying voltage level to a varying width pulse, the method comprising:a) generating a ramp signal for use as an input to a comparator; b)providing a photodetector output signal as an input to the comparator;c) producing an output signal of the comparator having a crossoverpoint; and d) sampling the output signal of the comparator to produce adigital pulse of a width proportional to the varying voltage level. 11.The method of claim 9, wherein the ramp voltage is provided by acapacitor coupled to a pulsed signal.
 12. The method of claim 9, whereinthe ramp voltage varies between a minimum voltage and a maximum voltage.13. The method of claim 9, wherein the average crossover point occursbetween a second sample and a second to last sample by themicrocontroller.